#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

vector<int> getSeq(int num[], int size)
{
    vector<int> ans;
    vector<int> dp1(size, -1);    
    vector<int> dp2(size, -1);    
    int pre;

    pre = num[0];
    for (int i = 1; i < size; i++) {
       if (pre < num[i]) dp1[i] = pre;
       if (num[i] < pre) pre = num[i]; 
    }

    pre = num[size-1];
    for (int i = size-2; i >= 0; i--) {
       if (pre > num[i]) dp2[i] = pre;
       if (num[i] > pre) pre = num[i]; 
    }
    for (int i = 1; i < size-1; i++) {
        if (dp1[i] != -1 && dp2[i] != -1) 
            cout << dp1[i] << " " << num[i] << " " << dp2[i] << " " << endl;
    }
    
    return ans;
}

int main(int argc, char **argv)
{

    cout << "-----------------Test 1--------------------" << endl;
    int test1[] = {12, 11, 10, 5, 6, 2, 30};
    vector<int> ans = getSeq(test1, sizeof(test1)/sizeof(int));
    for (int i = 0; i < ans.size(); i++) 
        cout << ans[i] << " ";
    cout << endl;

    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
